// pages/business/newBusiness/newBusiness.js
import {request,Modal} from "../../../../utils/util"
import {IMG_PATH,apiList,ApiRootUrl} from "../../../../config/index"
import Toast from '../../../../@vant/weapp/toast/toast';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    evaluateInfo:'',
    buweiList: [{
      id: new Date().getTime(),
      staffDTOList:[{
        staffName:'',
        staffSexText:'',
        staffSex:'',
        cameraNum:'',
        staffAddr:'',
        staffOffice:'',
      }]
    }],
    baseinfo:{},
    active:0,
    orgCode:'',
    processCode:'',
    feedback:"",
    dataInfo:{},
    imgList:[],
    videoList:[],
    video_lA:'',
    img_lA:[],
    tabList:[{
      value:'基本信息',
    },{
      value:'安防系统信息'
    },{
      value:'重点要害部位'
    }],
    shifouList:[
      {
        text:'否',
        value:0
      },
      {
        text:'是',
        value:1
      }
    ],
    dictionariesList:[],
    showDictionaries:false,
    companyTypeText:'',
    companyType:'',
    manageLevelText:'',
    manageLevel:'',
    showmanageLevel:false,
    manageLevelList:[
      {value:1,text:'社区管单位'},
      {value:2,text:'所管单位'},
      {value:3,text:'分局管单位'},
      {value:4,text:'市局管单位'},
      {value:5,text:'省管单位'},
    ],
    buildNatureText:'',
    buildNature:'',
    showbuildNature:false,
    buildNatureList:[
      {value:1,text:'商业楼'},
      {value:2,text:'商住楼'},
      {value:3,text:'办公楼'},
      {value:4,text:'居民楼'},
      {value:5,text:'沿街商铺'},
    ],
    companyName:'',
    companyAddr:'',
    fireLevel:'',
    fireLevelText:'',
    showfireLevel:false,
    fireLevelList:[
      {value:1,text:'一级'},
      {value:2,text:'二级'},
      {value:3,text:'三级'},
      {value:4,text:'一般'},
      {value:9,text:'其他'},
    ],
    girdCode:'',
    girdCodeText:'',
    showgirdCode:false,
    girdCodeList:[],
    registerTimeShow: false,
    registerTime:'',
    currentDate: new Date().getTime(),
    minDate: new Date(1920, 1, 1).getTime(),
    maxDate: new Date(2050, 1, 1).getTime(),
    maxDate1: new Date().getTime(),
    formatter(type, value) {
      if (type === 'year') {
        return `${value}`;
      } else if (type === 'month') {
        return `${value}`;
      }
      return value;
    },
    // enterpriseStatus:'',
    // enterpriseStatusText:'',
    // showenterpriseStatus:false,
    // enterpriseStatusList:[
    //   {value:'0',text:'正常'},
    //   {value:'1',text:'注销'}
    // ],
    isSpecial:'',
    isSpecialText:'',
    showisSpecial:false,
    specialType:'',
    specialTypeText:'',
    showspecialType:false,
    specialTypeList:[], 
    registerFunds:'',
    registerAddr:'',
    companyPhone:'',
    companyPhone:'',
    companyFax:'',
    specialNumber:'',
    isMajor:'',
    isMajorText:'',
    showisMajor:false,
    majorType:'',
    majorTypeText:'',
    showmajorType:false,
    majorTypeList:[{
      value:'1',
      text:'反恐重点单位'
    },{
      value:'2',
      text:'反恐要素单位'
    }], 
    majorLevel:'',
    majorLevelText:'',
    showmajorLevel:false,
    majorLevelList:[{
      value:'1',
      text:'一级'
    },{
      value:'2',
      text:'二级'
    },{
      value:'3',
      text:'三级'
    }], 
    internalStandard:'',
    internalStandardText:'',
    showinternalStandard:false,
    internalStandardList:[{
      value:'0',
      text:'是'
    },{
      value:'1',
      text:'否'
    }], 
    weightNetwork:'',
    weightNetworkText:'',
    showweightNetwork:false,
    weightNetworkList:[{
      value:'01',
      text:'公安图像传输专网'
    },{
      value:'02',
      text:'互联网'
    },{
      value:'04',
      text:'单位专网或局域网'
    }], 
    category:'',
    categoryText:'',
    showcategory:false,
    categoryList:[{
      value:'01',
      text:'财会室'
    },{
      value:'02',
      text:'危险品库'
    },{
      value:'03',
      text:'易制毒/易制爆化学品仓库'
    }], 
    staffSex:'',
    staffSexText:'',
    showstaffSex:false,
    staffSexList:[{
      value:'0',
      text:'男'
    },{
      value:'1',
      text:'女'
    }], 
    positionHigh:'',
    positionHighText:'',
    showpositionHigh:false,
    borderHigh:'',
    borderHighText:'',
    showborderHigh:false,
    positionHigh1:'',
    positionHighText1:'',
    showpositionHigh1:false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let self=this
    console.log(options);
    self.setData({
      userinfo:wx.getStorageSync('userinfo'),
      orgCode:options.orgCode,
      processCode:options.processCode
    })
    // self.getDetail()
    self.queryBusinessDetail()
  },
  staffNameblur(e){
    console.log(e);
    let data=this.data.buweiList
    let index=e.currentTarget.dataset.index
    let idx=e.currentTarget.dataset.idx
    data[index].staffDTOList[idx].staffName=e.detail.value
    this.setData({
      buweiList:data
    }
    )
  },
  staffIdentityblur(e){
    console.log(e);
    let data=this.data.buweiList
    let index=e.currentTarget.dataset.index
    let idx=e.currentTarget.dataset.idx
    data[index].staffDTOList[idx].staffIdentity=e.detail.value
    this.setData({
      buweiList:data
    }
    )
  },
  staffAddrblur(e){
    console.log(e);
    let data=this.data.buweiList
    let index=e.currentTarget.dataset.index
    let idx=e.currentTarget.dataset.idx
    data[index].staffDTOList[idx].staffAddr=e.detail.value
    this.setData({
      buweiList:data
    }
    )
  },
  staffOfficeblur(e){
    console.log(e);
    let data=this.data.buweiList
    let index=e.currentTarget.dataset.index
    let idx=e.currentTarget.dataset.idx
    data[index].staffDTOList[idx].staffOffice=e.detail.value
    this.setData({
      buweiList:data
    }
    )
  },
  partNameblur(e){
    console.log(e);
    let data=this.data.buweiList
    let index=e.currentTarget.dataset.index
    data[index].partName=e.detail.value
    this.setData({
      buweiList:data
    }
    )
  },
  partPhoneblur(e){
    console.log(e);
    let data=this.data.buweiList
    let index=e.currentTarget.dataset.index
    data[index].partPhone=e.detail.value
    this.setData({
      buweiList:data
    }
    )
  },
  partPositionblur(e){
    console.log(e);
    let data=this.data.buweiList
    let index=e.currentTarget.dataset.index
    data[index].partPosition=e.detail.value
    this.setData({
      buweiList:data
    }
    )
  },
  partPositionblur(e){
    console.log(e);
    let data=this.data.buweiList
    let index=e.currentTarget.dataset.index
    data[index].partPosition=e.detail.value
    this.setData({
      buweiList:data
    }
    )
  },
  partLeaderblur(e){
    console.log(e);
    let data=this.data.buweiList
    let index=e.currentTarget.dataset.index
    data[index].partLeader=e.detail.value
    this.setData({
      buweiList:data
    }
    )
  },
  leaderIdentityblur(e){
    console.log(e);
    let data=this.data.buweiList
    let index=e.currentTarget.dataset.index
    data[index].leaderIdentity=e.detail.value
    this.setData({
      buweiList:data
    }
    )
  },
  staffNumblur(e){
    console.log(e);
    let data=this.data.buweiList
    let index=e.currentTarget.dataset.index
    data[index].staffNum=e.detail.value
    this.setData({
      buweiList:data
    }
    )
  },
  positionCameraCount1blur(e){
    console.log(e);
    let data=this.data.buweiList
    let index=e.currentTarget.dataset.index
    data[index].positionCameraCount=e.detail.value
    this.setData({
      buweiList:data
    }
    )
  },
  bindTextArea(e){
    this.setData({
      evaluateInfo:e.detail.value
    })
  },
  // 下一步及提交
  update(){
    let self=this
    if(self.data.active==0){
      self.setData({
        active:1
      })
      return
    }
    if(self.data.active==1){
      self.setData({
        active:2
      })
      return
    }
    if(self.data.active==2){
      Toast.loading({
        duration: 0,
        message: '提交中...',
        forbidClick: true,
      });

      // console.log(info);
      // return
      let params={
        evaluateInfo:this.data.evaluateInfo,
        processCode: this.data.processCode,
        companyType:this.data.companyType,
        manageLevel:this.data.manageLevel,
        buildNature:this.data.buildNature,
        companyName:this.data.companyName,
        companyAddr:this.data.companyAddr,
        girdCode:this.data.girdCode,
        companyPhone:this.data.companyPhone,
        companyFax:this.data.companyFax,
        fireLevel:this.data.fireLevel,
        peaceLeader:this.data.peaceLeader,
        peaceIdentity:this.data.peaceIdentity,
        peacePhone:this.data.peacePhone,
        legalPerson:this.data.legalPerson,
        legalIdentity:this.data.legalIdentity,
        
        registerTime:this.data.registerTime,
        registerFunds:this.data.registerFunds,
        registerAddr:this.data.registerAddr,
        // enterpriseStatus:this.data.enterpriseStatus,
        businessScope:this.data.businessScope,
        orgCode:this.data.userinfo.componentCode,
        isSpecial:this.data.isSpecial,
        specialType:this.data.isSpecial==0?'':this.data.specialType,
        specialNumber:this.data.isSpecial==0?'':this.data.specialNumber,
        isMajor:this.data.isMajor,
        majorType:this.data.isMajor==0?'':this.data.majorType,
        majorLevel:this.data.isMajor==0?'':this.data.majorLevel,
        tbSecurityProtectionDTO:{
          internalStandard:this.data.internalStandard,
          weightNetwork:this.data.weightNetwork,
          securityManager:this.data.securityManager,
          dutyPhone:this.data.dutyPhone,
          systemBrand:this.data.systemBrand,
          positionCameraCount:this.data.positionCameraCount,
          positionHigh:this.data.positionHigh,
          borderHigh:this.data.borderHigh,
          cameraNum:this.data.cameraNum,
          imageSave:this.data.imageSave,
        },
        majorPositionDTOList:this.data.buweiList
      }
      wx.request({
        url: `${ApiRootUrl}/cloudCheckTask/dealBusinessUpdate`,
        method: 'POST',
        header: {
          'content-type': 'application/json; charset=utf-8',
          'cookie': wx.getStorageSync("sessionid")
        },
        data:params,
        success(res) {
          if(res.data.code == 20000){
            Toast.clear();
            Toast({
              type: 'success',
              duration: 3000,
              message: '提交成功',
            });
            setTimeout(()=>{
              wx.navigateBack()
            },1000) 
          }else{
            Toast.clear();
            Toast({
              duration: 3000,
              forbidClick: true,
              type: 'fail',
              message: res.data.message,
            });
          }
        },
        fail(res){
          Toast.clear();
          Toast({
            duration: 3000,
            forbidClick: true,
            type: 'fail',
            message: '网络已断开',
          });
        }
      })
    }
  },
   //切换首页标签
   onChange(value){
    let self=this
    this.setData({
      active:value.detail.index
    })
   
  },
  getDetail(e) {
    let self = this;

      let params = {
        processCode: self.data.processCode,
        orgCode: self.data.orgCode
      }
      Toast.loading({
        message: '加载中...',
        mask: true,
        duration: 0,
        forbidClick: true,
      });
      wx.request({
        url: `${ApiRootUrl}/cloudCheckTask/queryCloudTaskDetail`,
        method: 'GET',
        header: {
          'content-type': 'application/json; charset=utf-8',
          'cookie': wx.getStorageSync("sessionid")
        },
        params: params,
        data: params,
        success(res) {
          Toast.clear();
          if (res.data.code == 20000) {
            console.log(res);
          }else {
            Toast({
              duration: 3000,
              forbidClick: true,
              type: 'fail',
              message: res.data.message,
              mask:true
            });
          }
        },
        fail(res) {
          Toast.clear();
          Toast({
            duration: 3000,
            forbidClick: true,
            type: 'fail',
            message: '网络已断开',
          });
        }
      })
 
  },
  queryBusinessDetail(e) {
    let self = this;

      let params = {
        orgCode: self.data.orgCode
      }
      Toast.loading({
        message: '加载中...',
        mask: true,
        duration: 0,
        forbidClick: true,
      });
      wx.request({
        url: `${ApiRootUrl}/cloudCheckTask/queryBusinessDetail`,
        method: 'GET',
        header: {
          'content-type': 'application/json; charset=utf-8',
          'cookie': wx.getStorageSync("sessionid")
        },
        params: params,
        data: params,
        success(res) {
          Toast.clear();
          if (res.data.code == 20000) {
            console.log(res.data.data);
            let baseInfo=res.data.data
            if(baseInfo.manageLevel){
              self.data.manageLevelList.forEach(item=>{
                if(item.value==baseInfo.manageLevel){
                  baseInfo.manageLevelText=item.text
                }
              })
            }
            if(baseInfo.buildNature){
              self.data.buildNatureList.forEach(item=>{
                if(item.value==baseInfo.buildNature){
                  baseInfo.buildNatureText=item.text
                }
              })
            }

            if(baseInfo.fireLevel){
              self.data.fireLevelList.forEach(item=>{
                if(item.value==baseInfo.fireLevel){
                  baseInfo.fireLevelText=item.text
                }
              })
            }
            // if(baseInfo.enterpriseStatus){
            //   self.data.enterpriseStatusList.forEach(item=>{
            //     if(item.value==baseInfo.enterpriseStatus){
            //       baseInfo.enterpriseStatusText=item.text
            //     }
            //   })
            // }
            if(baseInfo.isSpecial){
              self.data.shifouList.forEach(item=>{
                if(item.value==baseInfo.isSpecial){
                  baseInfo.isSpecialText=item.text
                }
              })
            }
            if(baseInfo.isMajor){
              self.data.shifouList.forEach(item=>{
                if(item.value==baseInfo.isMajor){
                  baseInfo.isMajorText=item.text
                }
              })
            }
            if(baseInfo.majorType){
              self.data.majorTypeList.forEach(item=>{
                if(item.value==baseInfo.majorType){
                  baseInfo.majorTypeText=item.text
                }
              })
            }
            if(baseInfo.majorLevel){
              self.data.majorLevelList.forEach(item=>{
                if(item.value==baseInfo.majorLevel){
                  baseInfo.majorLevelText=item.text
                }
              })
            }
            if(baseInfo.tbSecurityProtectionDTO.internalStandard){
              self.data.internalStandardList.forEach(item=>{
                if(item.value==baseInfo.tbSecurityProtectionDTO.internalStandard){
                  baseInfo.tbSecurityProtectionDTO.internalStandardText=item.text
                }
              })
            }
            if(baseInfo.tbSecurityProtectionDTO.positionHigh){
              self.data.shifouList.forEach(item=>{
                if(item.value==baseInfo.tbSecurityProtectionDTO.positionHigh){
                  baseInfo.tbSecurityProtectionDTO.positionHighText=item.text
                }
              })
            }
            if(baseInfo.tbSecurityProtectionDTO.borderHigh){
              self.data.shifouList.forEach(item=>{
                if(item.value==baseInfo.tbSecurityProtectionDTO.borderHigh){
                  baseInfo.tbSecurityProtectionDTO.borderHighText=item.text
                }
              })
            }
            if(baseInfo.tbSecurityProtectionDTO.weightNetwork){
              self.data.weightNetworkList.forEach(item=>{
                if(item.value==baseInfo.tbSecurityProtectionDTO.weightNetwork){
                  baseInfo.tbSecurityProtectionDTO.weightNetworkText=item.text
                }
              })
            }
            self.setData({
              companyTypeText:baseInfo.companyTypeName,
              companyType:baseInfo.companyType,
              manageLevelText:baseInfo.manageLevelText,
              manageLevel:baseInfo.manageLevel,
              buildNatureText:baseInfo.buildNatureText,
              buildNature:baseInfo.buildNature||'',
              companyName:baseInfo.companyName||'',
              companyAddr:baseInfo.companyAddr||'',
              girdCodeText:baseInfo.gridName||'',
              girdCode:baseInfo.girdCode||'',
              companyPhone:baseInfo.companyPhone||'',
              companyFax:baseInfo.companyFax||'',
              fireLevelText:baseInfo.fireLevelText||'',
              fireLevel:baseInfo.fireLevel||'',
              peaceLeader:baseInfo.peaceLeader||'',
              peaceIdentity:baseInfo.peaceIdentity||'',
              peacePhone:baseInfo.peacePhone||'',
              legalPerson:baseInfo.legalPerson||'',
              legalIdentity:baseInfo.legalIdentity||'',
              registerTime:baseInfo.registerTime||'',
              registerFunds:baseInfo.registerFunds||'',
              registerAddr:baseInfo.registerAddr||'',
              businessScope:baseInfo.businessScope||'',
              // enterpriseStatusText:baseInfo.enterpriseStatusText||'',
              // enterpriseStatus:baseInfo.enterpriseStatus||'',
              isSpecialText:baseInfo.isSpecialText||'',
              isSpecial:baseInfo.isSpecial||'',
              specialType:baseInfo.specialType||'',
              specialTypeText:baseInfo.specialTypeName||'',
              isMajorText:baseInfo.isMajorText||'',
              isMajor:baseInfo.isMajor||'',
              majorTypeText:baseInfo.majorTypeText||'',
              majorType:baseInfo.majorType||'',
              majorLevelText:baseInfo.majorLevelText||'',
              majorLevel:baseInfo.majorLevel||'',
              internalStandardText:baseInfo.tbSecurityProtectionDTO.internalStandardText||'',
              internalStandard:baseInfo.tbSecurityProtectionDTO.internalStandard||'',
              weightNetworkText:baseInfo.tbSecurityProtectionDTO.weightNetworkText||'',
              weightNetwork:baseInfo.tbSecurityProtectionDTO.weightNetwork||'',
              specialNumber:baseInfo.specialNumber||'',
              securityManager:baseInfo.tbSecurityProtectionDTO.securityManager||'',
              dutyPhone:baseInfo.tbSecurityProtectionDTO.dutyPhone||'',
              systemBrand:baseInfo.tbSecurityProtectionDTO.systemBrand||'',
              positionCameraCount:baseInfo.tbSecurityProtectionDTO.positionCameraCount||'',
              positionHighText:baseInfo.tbSecurityProtectionDTO.positionHighText||'',
              positionHigh:baseInfo.tbSecurityProtectionDTO.positionHigh||'',
              borderHighText:baseInfo.tbSecurityProtectionDTO.borderHighText||'',
              borderHigh:baseInfo.tbSecurityProtectionDTO.borderHigh||'',
              cameraNum:baseInfo.tbSecurityProtectionDTO.cameraNum||'',
              imageSave:baseInfo.tbSecurityProtectionDTO.imageSave||'',
              
              
              buweiList:baseInfo.majorPositionDTOList||[{
                staffDTOList:[{}]
              }]
            })
          }else {
            Toast({
              duration: 3000,
              forbidClick: true,
              type: 'fail',
              message: res.data.message,
              mask:true
            });
          }
        },
        fail(res) {
          Toast.clear();
          Toast({
            duration: 3000,
            forbidClick: true,
            type: 'fail',
            message: '网络已断开',
          });
        }
      })
 
  },
  //单位类别
  dictionariesListCancel() {
    this.setData({
      showDictionaries: false
    })
  },
  dictionariesListConfirm(event) {
    console.log(event);
    this.setData({
      companyType: event.detail.value.value,
      companyTypeText: event.detail.value.text,
      showDictionaries:false
    })
  },
  getDictionariesList(e) {
    let self = this;
      let params = {
        dictionaryType: 'UnitCategory',
      }
      Toast.loading({
        message: '加载中...',
        mask: true,
        duration: 0,
        forbidClick: true,
      });
      wx.request({
        url: `${ApiRootUrl}/dictionaries/querytbDictionariesList`,
        method: 'GET',
        header: {
          'content-type': 'application/json; charset=utf-8',
          'cookie': wx.getStorageSync("sessionid")
        },
        params: params,
        data: params,
        success(res) {
          Toast.clear();
          if (res.data.code == 20000) {
            console.log(res);
            let dictionariesList=[]
            res.data.data.forEach(item=>{
              let obj={text:item.dictionaryName,
              value:item.dictionaryCode
              }
              dictionariesList.push(obj)
            })
            self.setData({
              dictionariesList:dictionariesList,
              showDictionaries:true
            })
          }else {
            Toast({
              duration: 3000,
              forbidClick: true,
              type: 'fail',
              message: res.data.message,
              mask:true
            });
          }
        },
        fail(res) {
          Toast.clear();
          Toast({
            duration: 3000,
            forbidClick: true,
            type: 'fail',
            message: '网络已断开',
          });
        }
      })
  },
  //管理级别
  manageLevelCancel() {
    this.setData({
      showmanageLevel: false
    })
  },
  manageLevelConfirm(event) {
    console.log(event);
    this.setData({
      manageLevel: event.detail.value.value,
      manageLevelText: event.detail.value.text,
      showmanageLevel:false
    })
  },
  getmanageLevel(e) {
    this.setData({
      showmanageLevel:true
    })
  },
  //消防等级
  fireLevelCancel() {
    this.setData({
      showfireLevel: false
    })
  },
  fireLevelConfirm(event) {
    console.log(event);
    this.setData({
      fireLevel: event.detail.value.value,
      fireLevelText: event.detail.value.text,
      showfireLevel:false
    })
  },
  getfireLevel(e) {
    this.setData({
      showfireLevel:true
    })
  },
  //所属责任区
  girdCodeCancel() {
    this.setData({
      showgirdCode: false
    })
  },
  girdCodeConfirm(event) {
    console.log(event);
    this.setData({
      girdCode: event.detail.value.value,
      girdCodeText: event.detail.value.text,
      showgirdCode:false
    })
  },
  getgirdCode(e) {
    let self = this;
    let params = {
    }
    Toast.loading({
      message: '加载中...',
      mask: true,
      duration: 0,
      forbidClick: true,
    });
    wx.request({
      url: `${ApiRootUrl}/cloudCheckTask/queryAllGirds`,
      method: 'GET',
      header: {
        'content-type': 'application/json; charset=utf-8',
        'cookie': wx.getStorageSync("sessionid")
      },
      params: params,
      data: params,
      success(res) {
        Toast.clear();
        if (res.data.code == 20000) {
          console.log(res);
          let girdCodeList=[]
          res.data.data.forEach(item=>{
            let obj={text:item.gridName,
            value:item.id
            }
            girdCodeList.push(obj)
          })
          self.setData({
            girdCodeList:girdCodeList,
            showgirdCode:true
          })
        }else {
          Toast({
            duration: 3000,
            forbidClick: true,
            type: 'fail',
            message: res.data.message,
            mask:true
          });
        }
      },
      fail(res) {
        Toast.clear();
        Toast({
          duration: 3000,
          forbidClick: true,
          type: 'fail',
          message: '网络已断开',
        });
      }
    })
  },
  //注册日期
  getregisterTime(event) {
    this.setData({
      registerTimeShow: true,
    })
  },
  registerTimeCancel() {
    this.setData({
      registerTimeShow: false,
    })
  },
  registerTimeConfirm(event) {
    let time = this.formatDate(event.detail);

    this.setData({
      registerTime: time,
      registerTimeShow: false
    })
  },
  formatDate(date) {
    var date = new Date(date);
    var YY = String(date.getFullYear()) ;
    var MM = String((date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)) ;
    var DD = String((date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate())) ;
    return YY + MM + DD;
  },
  //机构状态
  // enterpriseStatusCancel() {
  //   this.setData({
  //     showenterpriseStatus: false
  //   })
  // },
  // enterpriseStatusConfirm(event) {
  //   console.log(event);
  //   this.setData({
  //     enterpriseStatus: event.detail.value.value,
  //     enterpriseStatusText: event.detail.value.text,
  //     showenterpriseStatus:false
  //   })
  // },
  // getenterpriseStatus(e) {
  //   this.setData({
  //     showenterpriseStatus:true
  //   })
  // },
  //是否是特种行业
  isSpecialCancel() {
    this.setData({
      showisSpecial: false
    })
  },
  isSpecialConfirm(event) {
    console.log(event);
    this.setData({
      isSpecial: event.detail.value.value,
      isSpecialText: event.detail.value.text,
      showisSpecial:false
    })
  },
  getisSpecial(e) {
    this.setData({
      showisSpecial:true
    })
  },
  //特种行业类别
  specialTypeCancel() {
    this.setData({
      showspecialType: false
    })
  },
  specialTypeConfirm(event) {
    console.log(event);
    this.setData({
      specialType: event.detail.value.value,
      specialTypeText: event.detail.value.text,
      showspecialType:false
    })
  },
  getspecialType(e) {
    let self = this;
      let params = {
        dictionaryType: 'SpecialLineCategory',
      }
      Toast.loading({
        message: '加载中...',
        mask: true,
        duration: 0,
        forbidClick: true,
      });
      wx.request({
        url: `${ApiRootUrl}/dictionaries/querytbDictionariesList`,
        method: 'GET',
        header: {
          'content-type': 'application/json; charset=utf-8',
          'cookie': wx.getStorageSync("sessionid")
        },
        params: params,
        data: params,
        success(res) {
          Toast.clear();
          if (res.data.code == 20000) {
            console.log(res);
            let specialTypeList=[]
            res.data.data.forEach(item=>{
              let obj={text:item.dictionaryName,
              value:item.dictionaryCode
              }
              specialTypeList.push(obj)
            })
            self.setData({
              specialTypeList:specialTypeList,
              showspecialType:true
            })
          }else {
            Toast({
              duration: 3000,
              forbidClick: true,
              type: 'fail',
              message: res.data.message,
              mask:true
            });
          }
        },
        fail(res) {
          Toast.clear();
          Toast({
            duration: 3000,
            forbidClick: true,
            type: 'fail',
            message: '网络已断开',
          });
        }
      })
  },
  //是否是反恐重点单位
  isMajorCancel() {
    this.setData({
      showisMajor: false
    })
  },
  isMajorConfirm(event) {
    console.log(event);
    this.setData({
      isMajor: event.detail.value.value,
      isMajorText: event.detail.value.text,
      showisMajor:false
    })
  },
  getisMajor(e) {
    this.setData({
      showisMajor:true
    })
  },
  //反恐重点单位类型
  majorTypeCancel() {
    this.setData({
      showmajorType: false
    })
  },
  majorTypeConfirm(event) {
    console.log(event);
    this.setData({
      majorType: event.detail.value.value,
      majorTypeText: event.detail.value.text,
      showmajorType:false
    })
  },
  getmajorType(e) {
    this.setData({
      showmajorType:true
    })
  },
  //反恐单位等级
  majorLevelCancel() {
    this.setData({
      showmajorLevel: false
    })
  },
  majorLevelConfirm(event) {
    console.log(event);
    this.setData({
      majorLevel: event.detail.value.value,
      majorLevelText: event.detail.value.text,
      showmajorLevel:false
    })
  },
  getmajorLevel(e) {
    this.setData({
      showmajorLevel:true
    })
  },
  //建筑性质
  buildNatureCancel() {
    this.setData({
      showbuildNature: false
    })
  },
  buildNatureConfirm(event) {
    console.log(event);
    this.setData({
      buildNature: event.detail.value.value,
      buildNatureText: event.detail.value.text,
      showbuildNature:false
    })
  },
  getbuildNature() {
    this.setData({
      showbuildNature:true
    })
  },
  //是否符合国标
  internalStandardCancel() {
    this.setData({
      showinternalStandard: false
    })
  },
  internalStandardConfirm(event) {
    console.log(event);
    this.setData({
      internalStandard: event.detail.value.value,
      internalStandardText: event.detail.value.text,
      showinternalStandard:false
    })
  },
  getinternalStandard(e) {
    this.setData({
      showinternalStandard:true
    })
  },
  //承载网络
  weightNetworkCancel() {
    this.setData({
      showweightNetwork: false
    })
  },
  weightNetworkConfirm(event) {
    console.log(event);
    this.setData({
      weightNetwork: event.detail.value.value,
      weightNetworkText: event.detail.value.text,
      showweightNetwork:false
    })
  },
  getweightNetwork(e) {
    this.setData({
      showweightNetwork:true
    })
  },
  //重点部位是否高清
  positionHighCancel() {
    this.setData({
      showpositionHigh: false
    })
  },
  positionHighConfirm(event) {
    console.log(event);
    this.setData({
      positionHigh: event.detail.value.value,
      positionHighText: event.detail.value.text,
      showpositionHigh:false
    })
  },
  getpositionHigh(e) {
    this.setData({
      showpositionHigh:true
    })
  },
  //边界是否高清
  borderHighCancel() {
    this.setData({
      showborderHigh: false
    })
  },
  borderHighConfirm(event) {
    console.log(event);
    this.setData({
      borderHigh: event.detail.value.value,
      borderHighText: event.detail.value.text,
      showborderHigh:false
    })
  },
  getborderHigh(e) {
    this.setData({
      showborderHigh:true
    })
  },
  //类别
  categoryCancel() {
    this.setData({
      showcategory: false
    })
  },
  categoryConfirm(event) {
    console.log(event);
    let buweiList=this.data.buweiList
    buweiList[this.data.categoryIndex].category=event.detail.value.value
    buweiList[this.data.categoryIndex].categoryText=event.detail.value.text
    this.setData({
      buweiList:buweiList,
      showcategory:false
    })
  },
  getcategory(e) {
    console.log(e);
    this.setData({
      categoryIndex:e.currentTarget.dataset.index
    })
    this.setData({
      showcategory:true
    })
  },
  //重点要害摄像机是否高清
  positionHigh1Cancel() {
    this.setData({
      showpositionHigh1: false
    })
  },
  positionHigh1Confirm(event) {
    console.log(event);
    let buweiList=this.data.buweiList
    buweiList[this.data.categoryIndex].positionHigh=event.detail.value.value
    buweiList[this.data.categoryIndex].positionHighText=event.detail.value.text
    this.setData({
      buweiList:buweiList,
      showpositionHigh1:false
    })
  },
  getpositionHigh1(e) {
    console.log(e);
    this.setData({
      categoryIndex:e.currentTarget.dataset.index
    })
    this.setData({
      showpositionHigh1:true
    })
  },
  
  //性别
  staffSexCancel() {
    this.setData({
      showstaffSex: false
    })
  },
  staffSexConfirm(event) {
    console.log(event);
    let buweiList=this.data.buweiList
    let index=this.data.staffSexindex
    let idx=this.data.staffSexidx
    buweiList[index].staffDTOList[idx].staffSex=event.detail.value.value
    buweiList[index].staffDTOList[idx].staffSexText=event.detail.value.text
    this.setData({
      buweiList:buweiList,
      showstaffSex:false
    })
  },
  getstaffSex(e) {
    console.log(e);
    this.setData({
      staffSexindex:e.currentTarget.dataset.index,
      staffSexidx:e.currentTarget.dataset.idx
    })
    this.setData({
      showstaffSex:true
    })
  },
  
  //新增工作人员
  addperson(e){
console.log(e);
let num=e.currentTarget.dataset.index
    let data = this.data.buweiList[num].staffDTOList;
    data.push({
      id: new Date().getTime(),
      staffName:'',
      staffSexText:'',
      staffSex:'',
      cameraNum:'',
      staffAddr:'',
      staffOffice:'',
    })
    let newData=this.data.buweiList
    newData[num].staffDTOList=data
    this.setData({
      buweiList: newData
    })
  },
  //
  addarea(event) {
    console.log(event);

    let data = this.data.buweiList;
    data.push({
      id: new Date().getTime(),
      staffDTOList:[{
        id: new Date().getTime(),
        staffName:'',
        staffSexText:'',
        staffSex:'',
        cameraNum:'',
        staffAddr:'',
        staffOffice:'',
      }]
    })
    this.setData({
      buweiList: data
    })
  },
  deletebuwei(e){
    console.log(e);
    let data=this.data.buweiList
    if (data && data.length == 1) {
      Toast('无法删除!')
      return;
    } else {
      data.forEach((item, index) => {
        if (item.id == e.currentTarget.dataset.id) {
          data.splice(index, 1)
        }
      })
    }
    this.setData({
      buweiList: data
    })
  },
  deleteperson(e){
    console.log(e);
    let index=e.currentTarget.dataset.index
    let buweiList=this.data.buweiList
    let data=buweiList[index].staffDTOList
    if (data && data.length == 1) {
      Toast('无法删除!')
      return;
    } else {
      data.forEach((item, index) => {
        if (item.id == e.currentTarget.dataset.id) {
          data.splice(index, 1)
        }
      })
    }
    this.setData({
      buweiList: buweiList
    })

  },



  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})